/**
 * Created by Administrator on 2018/2/24 0024.
 */


operateFormatter = function (value, row, index) {
    return [
        '<a class="agree" href="javascript:void(0)" >同意审核</a>' +
        '&nbsp;&nbsp;'
        // '<a class="refuse" href="javascript:void(0)" >拒绝审核</a>'
    ].join('');
};

operateEvent = {
    'click .agree': function (e, value, row) {
        showModel("queryWaiterService-div", function () {
            $("#id").val(row.id);
            $("#time").val(row.payTime);
            $("#money ").val(row.payMoney);
            $("#star").val(row.star);
            if (row.personalPic != null) {
                $("#showPer").show();
            } else {
                $("#showPer").hide();
            }
            if (row.businessPic != null) {
                $("#showBus").show();
            } else {
                $("#showBus").hide();
            }
            var path = File_Download_Url;
            $("#picPer ").attr("src", path + row.personalPic);
            $("#picBus ").attr("src", path + row.businessPic);
        })
    }
};


/**
 * 确认添加按钮事件
 */
bindClick("button[data-event=submit-waiterBusiness]", function () {
    var id = $("#id").val();
    var star = $("#star").val();
    var form = $("#throughWaiterServiceFrom");
    if (star > 5) {
        hint('评分不能超过5！');
        return;
    }
    var param = form.formToArray();
    $.post($().AbsUrlParse('/web/waiterService/throughService'), {id: id, starWaiter: star}, function (res) {
        if (res.state && res.res.code == 40000) {
            hint('审核成功');
            //关闭model方法
            closeModel('queryWaiterService-div');
            var table = $("#table");
            table.bootstrapTable("refresh");
        } else {
            if (res.state == false) {
                hint(res.msg);
            } else {
                hint(res.res.msg);
            }
        }
    });
});


var queryWaiter = function () {
    var name = $("#name").val();
    var url = $().AbsUrlParse("/web/waiterService/queryAuditingBus?waiterName=" + name);
    var table = $("#table");
    table.bootstrapTable("refresh", {url: url});
};
picture = function (value, row, index) {
    var personalPic = row.personalPic;
    var businessPic = row.businessPic;
    var img = "";
    if (personalPic != null) {
        img = personalPic;
    } else {
        img = businessPic;
    }
    var imgUrl = "";
    if (img != null && img != '') {
        imgUrl = File_Download_Url + img;
        return [
            '<image src=' + imgUrl + ' style="width:120px;height:80px" onclick="enlargePic(this)"  />'
        ].join('');
    } else {
        return [
            '<image src=' + $().AbsUrlParse("/static/images/no.png") + ' style="width:120px;height:80px" onclick="enlargePic(this)" />'
        ].join('');
    }
};
function enlargePic(value) {
    showModel("showBigPhoto-div", function () {
        var imgs = '<image src=' + value.src + ' style="height:600px" />';
        $("#showBigPhoto").html(imgs);
    })
}